import { createRoot } from 'react-dom/client'
import App from './pages/app';
import { BrowserRouter } from 'react-router-dom';
import './global.less'
import '@ant-design/v5-patch-for-react-19';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/locale/zh_CN';
import 'dayjs/locale/zh-cn';

const root = document.querySelector('#root')
try {
  let canvas = document.createElement('canvas');
  let ctx = canvas.getContext('2d');
  canvas.width = 100;
  canvas.height = 100;
  ctx?.fillRect(0, 0, 100, 100);
  ctx!.fillStyle = "#ffffff";
  ctx!.font = "70px 微软雅黑";
  ctx?.fillText('洪', 15, 70);
  let src = canvas.toDataURL("image/png");
  console.log("src");
  localStorage.setItem("logo", src)
  document.head.querySelectorAll("link").forEach(item => {
    if (item.rel == "icon") {
      item.href = src
    }
  })
} catch (err) {
  console.error(err);

}
if (root) {
  createRoot(root).render(
    <ConfigProvider locale={zhCN}>
      <BrowserRouter>
        <App />
      </BrowserRouter>
    </ConfigProvider>
  )
}